Metaprogramming Ruby 2

Metaprogramming Ruby 2
Author: Paolo Perrotta
Language: eng
Format: epub
Tags: Pragmatic Bookshelf
ISBN: 978-1-94122-212-6
Publisher: The Pragmatic Bookshelf, LLC

​ ​def​ self.now; ​'Mon Apr 06 12:15:50'​; ​end​

​ ​end​

​

​ require ​'test/unit'​

​

​ ​class​ TestLoan < Test::Unit::TestCase

​ ​def​ test_conversion_to_string

​ Loan.instance_eval { @time_class = FakeTime }

​ loan = Loan.new(​'War and Peace'​)

​ assert_equal ​'WAR AND PEACE loaned on Mon Apr 06 12:15:50'​, loan.to_s

​ ​end​

​ ​end​

Bill is quite proud of his own coding prowess. He says, “I think we deserve a break—after I give you a quiz.”